//
//  DoctorDetailregistrationCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/4/20.
//  Copyright © 2020 QDSG. All rights reserved.
//

import UIKit

protocol DoctorDetailregistrationCellDelegate: NSObjectProtocol {
    func doctorDetailregistrationCellBtnAction(indexPath: IndexPath)
}

class DoctorDetailregistrationCell: UITableViewCell {
    
    var indexPath: IndexPath = IndexPath(row: 0, section: 0)
    weak var delegate: DoctorDetailregistrationCellDelegate?
    
    func updateData(vm: DoctorScheduleViewModel, indexPath: IndexPath) {
        self.indexPath = indexPath
        timeLabel.text = vm.scheduleTime
        feeLabel.text = vm.regFee + "元"
        registrationBtn.isEnabled = vm.status.canReserve
        registrationBtn.backgroundColor = vm.status.bgColorForGeneral
        
        registrationBtn.setTitleColor(vm.status.newTextColor, for: .normal)
        
        departmentLabel.text = vm.departmentName
    }
    
    @IBAction func registrationBtnAction(_ sender: Any) {
        delegate?.doctorDetailregistrationCellBtnAction(indexPath: indexPath)
    }
    
    @IBOutlet private weak var departmentLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var feeLabel: UILabel!
    @IBOutlet weak var registrationBtn: UIButton! {
        didSet {
            registrationBtn.layer.cornerRadius = registrationBtn.height / 2.0
            registrationBtn.layer.masksToBounds = true
        }
    }
    
}
